<template>
	<div class="components-container">
        <div class="header-form">
            <div class="layui-inline">
              <label >区域名称</label>
                <div class="layui-input-inline">
                  <el-input v-model="selectData.asanameLike" placeholder="请输入区域名称"></el-input>
                </div>
            </div>
            <el-button type="primary" @click="btnSearch" :loading="this.$store.state.isloading">搜索</el-button>
            <el-button  @click="btnRepeat">重置</el-button>
        </div>
        <div>
          <ul class="toolList">
              <li v-if="btnShow(item.BTNVALUE)" v-for="(item, index) in $store.state.btnListCommon" @click="operate(item.BTNVALUE)">
                  <el-button type="primary" :value="item.BTNSHOWNAME" v-text="item.BTNSHOWNAME"></el-button>
              </li>
          </ul>
        </div>
        <dataTable :headList="headList" :dataList="dataList" :pageOrder="pageOrder" @pageChange="pageChange" @selectRow="selectRow"></dataTable>
        
        <ashesAreaMain ref="sweetModalMain" :orderType="order" @refreshData="getData"></ashesAreaMain>
	</div>


</template>
<style rel="stylesheet/scss" lang="scss" scoped>
    @import "src/styles/common.scss";
    .el-button + .el-button {
      margin-left: 0;
    }
    .btn {
      text-align: center;
    }
</style>
<script>
import ashesAreaMain from "./ashesAreaMain";
import dataTable from "@/components/Table/DataTable";
import apiBase from "@/api/apiBase.js";
import { formatDate, timeStringToDate } from "@/utils/date.js";
import { manage } from "@/mixins/managePage.js";

const ADD = "新增";
const MODIFY = "修改";
const DELETE = "删除";
const INFO = "详情";

export default {
  name: "ashesArea",
  mixins: [manage],
  data() {
    return {
      loading: false,
      headList: [],
      selectData: {},
      ashesAreaData: {}
    };
  },
  methods: {
    //区域查询
    getData() {
      let data = {
        PageIndex: this.pageOrder.currentPage,
        PageSize: this.pageOrder.pageSize,
        OrderBy: this.pageOrder.orderType,
        OrderByType: this.pageOrder.orderSort,
        Data: JSON.parse(JSON.stringify(this.selectData))
      };
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Ashesarea.Query,
        res => {
          this.dataList = res.data.content.OutData;
          this.pageOrder.totalNum = res.data.content.RecordCount;
        },
        res => {
          this.$message.error(res.data.msg);
        }
      );
    },
    //获取表头
    getAsaColumns() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Column.GetAshesareaColumns,
        res => {
          this.headList = res.data.content;
        },
        res => {
          this.$message.error(res.data.msg);
        }
      );
    },
    //功能操作
    operate(order) {
      this.order = order;
      this.dataRepeat();
      switch (this.order) {
        case ADD:
          this.$refs.sweetModalMain.open(this.order);
          break;
        case MODIFY:
        case INFO:
          this.$refs.sweetModalMain.open(this.order, this.currentRow.ASAID);
          break;
        case DELETE:
            this.$refs.sweetModalMain.open(this.order, this.currentRow.ASAID);
          break;
        default:
      }
    },
    //查询条件重置
    btnRepeat() {
      this.selectData = {};
      this.getData();
    },
    //数据重置
    dataRepeat() {
      this.ashesAreaData = {};
    }
  },
  components: {
    ashesAreaMain,
    dataTable
  },
  mounted() {},
  created() {
    this.getData();
    this.getAsaColumns();
  }
};
</script>